﻿import kliment.display.SpriteBtn;
/**
 * ...
 * @author	Kliment
 * @version	1.1.0
 */
class kliment.controls.CheckBox extends SpriteBtn {
	private var _point_mc:MovieClip;
	private var _value:Boolean = false;
	public var onChange:Function;
	
	public function CheckBox(target_mc:MovieClip) {
		super(target_mc);
		_point_mc = _target_mc.point_mc;
		addListener(this);
		_uncheck();
	}
	
	public function get value():Boolean { return _value; }
	public function set value(value:Boolean):Void {
		if (value != _value) {
			if (value) 
				_check();
			else 
				_uncheck();
			_value = value;
			onChange(this);
			broadcastMessage('onChange', this);
		}
	}
	
	private function _check():Void {
		_point_mc._visible = true;
	}
	
	private function _uncheck():Void {
		_point_mc._visible = false;
	}
	
	public function setFocus():Void {
		
	}
	
	public function resetFocus():Void {
		
	}
	
	private function onRelease():Void {
		value = !value;
	}
	
	private function onRollOver():Void {
		setFocus();
	}
	
	private function onRollOut():Void {
		resetFocus();
	}
	
	private function onReleaseOutside():Void {
		resetFocus();
	}
	
}